﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;

namespace HQWeb.View
{
    /// <summary>
    /// GetSearchIndex 获得项目查询
    /// </summary>
    public class GetSearchIndex : IHttpHandler
    {
        public static string strHtml="";
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            strHtml = strHtml == "" ? GetSearchInde() : strHtml;
            context.Response.Write(strHtml);
        }

        private string GetSearchInde()
        {
            StringBuilder strHtml = new StringBuilder();
            BLL.SysManage.T_PUB_PROJECTTYPE typeBll = new BLL.SysManage.T_PUB_PROJECTTYPE();
            List<Model.SysManage.T_PUB_PROJECTTYPE> typeList = typeBll.GetModelList("");
            IEnumerable<Model.SysManage.T_PUB_PROJECTTYPE> parentList = typeList.Where(p => p.PARENT_ID == 0);//  获得一级索引
            IEnumerable<Model.SysManage.T_PUB_PROJECTTYPE> nodeList;
            foreach (Model.SysManage.T_PUB_PROJECTTYPE item in parentList)
            {
                strHtml.Append(string.Format("<h3> <a href=\"#\">{0}</a> </h3> <ul>", item.PROJECTTYPE_NAME));
                nodeList = typeList.Where(p => p.PARENT_ID == item.PROJECTTYPE_ID);

                foreach (Model.SysManage.T_PUB_PROJECTTYPE items in nodeList)
                {
                    strHtml.Append(string.Format("<li><a href=\"#\"  onclick=\"getPage('{0}')\">{1}</a> </li>", items.PROJECTTYPE_ID,items.PROJECTTYPE_NAME));
                }
                strHtml.Append("</ul>");
            }
            strHtml.Append("</br>");
            strHtml.Append("</br>");
            strHtml.Append("</br>");
            return strHtml.ToString();
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}